import fly from "./main"


/**
 * 商家登录
 * @param $params
 * @returns {*}
 */
export function doLogin($params) {
  return fly.post('/v2/login', $params)
}

/**
 * 发送验证码
 * @param $params
 * @returns {*}
 */
export function doSendVerify($params) {
  return fly.post('/v2/sms', $params);
}

/**
 * 商家注册
 * @param $params
 * @returns {*}
 */
export function doRegister($params) {
  return fly.post('/v2/regist', $params)
}

/**
 * 获取积分
 * @returns {*}
 */
export async function getScore() {
  let response = {}
  await fly.get(`v2/score`).then((res) => {
    response = res.data
  })
  return response;
}


/**
 *  获取订单
 * @returns {Promise<{}>}
 */
export async function getOrder() {
  let response = {}
  let $params = {}
  $params['page'] = 1
  $params['size'] = 10
  await fly.get('v2/order', $params).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 获取身份证信息
 * @returns {*}
 */
export function getIdCards() {
  return fly.get('/v2/idCard')
}

/**
 * 新增身份证信息
 * @param $params
 * @returns {*}
 */
export function addIdCard($params) {
  return fly.post('/v2/idCard', $params)
}

/**
 * 修改身份证信息
 * @param $params
 * @returns {*}
 */
export function changeIdCard($params) {
  return fly.put('/v2/idCard/' + $params['id'], $params)
}

/**
 * 删除身份证信息
 * @param $params
 * @returns {*}
 */
export function deleteIdCard($params) {
  return fly.delete('/v2/idCard/' + $params['id'])
}


/**
 * 获取银行卡信息
 * @returns {*}
 */
export function getBankCards() {
  let $params = {}
  $params['page'] = 1;
  $params['size'] = 10;
  return fly.get('/v2/bankCard', $params)
}

/**
 * 新增银行卡信息
 * @param $params
 * @returns {*}
 */
export function addBankCards($params) {
  return fly.post('/v2/bankCard', $params)
}

/**
 * 修改银行卡信息
 * @param $params
 * @returns {*}
 */
export function changeBankCards($params) {
  let $data = {"card_name": $params['card_name']}
  return fly.put('/v2/bankCard/' + $params['id'], $data)
}

/**
 * 删除银行卡信息
 * @param $params
 * @returns {*}
 */
export function deleteBankCards($params) {
  return fly.delete('/v2/bankCard/' + $params['id'])
}


/**
 * 获取地址列表
 * @returns {*}
 */
export function getAddress() {
  return fly.get('/v2/address')
}

/**
 * 根据pid获取地址
 * @param $params
 * @returns {*}
 */
export function getpAddress($params) {
  return fly.get('/v2/address/' + $params)
}


/**
 * 获取账户积分
 * @returns {*}
 */
export function getUserScore() {
  return fly.get('/v2/score/1')
}

/**
 * 获取积分列表
 * @returns {*}
 */
export function getScoreList() {
  let $params = {}
  $params['page'] = 1;
  $params['size'] = 1000;
  return fly.get('/v2/score', $params)
}

/**
 * 积分提现
 * @param $params
 * @returns {*}
 */
export function changeScore($params) {
  return fly.post('/v2/score', $params)
}


/**
 * 获取登录的商家信息
 * @returns {*}
 */
export async function getUserInfo() {
  let response = {}
  await fly.get(`/v2/user/1`).then((res) => {
    response = res.data
  })
  return response;
}


/**
 * 查看开放的区域
 * @returns {Promise<{}>}
 */
export async function getOpenRegion() {
  let response = {}
  await fly.get(`/v2/region`).then((res) => {
    response = res.data
  })
  return response;
}


